package com.appkubes.mall.admin.application.promoter.promoter.dao;

import com.appkubes.mall.admin.application.promoter.promoter.entity.dto.PromoterStatisDTO;
import com.appkubes.mall.admin.application.promoter.promoter.entity.vo.PromoterSearchVO;
import com.appkubes.mall.core.dao.BaseMallPromoterDao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface PromoterDao extends BaseMallPromoterDao {

    @Select({"<script>",
            " select SUM(statis_reg_count) as regSum, SUM(statis_auth_count) AS authSum, SUM(statis_order_count) AS orderSum,",
            " SUM(statis_order_amount_count) as orderAmountSum, SUM(statis_order_orinal_amount_count) as originAmountSum, SUM(statis_download_count) as downloadSum",
            " FROM mall_promoter WHERE 1",
            " <when test='promoterSearchVO.name!=null'>",
            " AND promoter_name like '%${promoterSearchVO.name}%'",
            " </when>",
            "</script>"})
    PromoterStatisDTO statis(@Param("promoterSearchVO")PromoterSearchVO promoterSearchVO);
}
